package org.vectrics.recruiter.struts.mail;


import org.apache.log4j.Logger;
import org.vectrics.mail.struts.JobTemplateObject;
import org.vectrics.mail.struts.ObjectGraph;
import org.vectrics.mail.struts.TemplateObject;
import org.vectrics.recruiter.job.Job;


public class RecruitObjectGraph extends ObjectGraph {
	private Logger log = Logger.getLogger(this.getClass());
	
	protected TemplateObject translateObjectToGraphObject(Object originalObject) {
		TemplateObject templateObject = null;
		if (originalObject instanceof Job) {
			Job job = (Job)originalObject;
			JobTemplateObject jobObject = new JobTemplateObject();
			jobObject.setDescription(job.getDescription());
			jobObject.setTitle(job.getTitle());
			if (job.getPrimaryRecruiter() != null) {
				jobObject.setPrimaryRecruiter(job.getPrimaryRecruiter().getFullName());
			}
			if (job.getHiringManager() != null) {
				jobObject.setHiringManager(job.getHiringManager().getFullName());
			}
			if (job.getSalary() != null) {
				jobObject.setSalary(job.getSalary().toString());
			}
			templateObject = jobObject;
		} 
		
		if (templateObject == null) {
			templateObject = super.translateObjectToGraphObject(originalObject);
		} 
		return(templateObject);
	}

	
}
